/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CreateTable;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tashiba
 */
public class CreateTableUser {

    public static void main(String[] args) {

        try {
            try {
                Class.forName("com.mysql.jdbc.Driver");
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(CreateTableUser.class.getName()).log(Level.SEVERE, null, ex);
            }
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/pti", "root", "115314034");


            System.out.println("Koneksi is OK");
            Statement statement = conn.createStatement();
            String user = " CREATE TABLE USER (NIK VARCHAR(10) NOT NULL,"
                    + "NAMA VARCHAR(30), PASSWORD VARCHAR(15) NOT NULL, "
                    + "JABATAN VARCHAR(30) NOT NULL,"
                    + "CONSTRAINT USER_PK PRIMARY KEY (NIK));";

            statement.executeUpdate(user);
            System.out.println("Tabel USER Created");
        } catch (SQLException e) {
// perform error handling here
            System.out.println("error :" + e.getMessage());
        }
    }
}
